package com.tedu.parkinglot.role.controller;

import com.tedu.parkinglot.base.response.JsonResult;
import com.tedu.parkinglot.role.pojo.dto.RoleQuery;
import com.tedu.parkinglot.role.pojo.dto.RoleSaveParam;
import com.tedu.parkinglot.role.pojo.vo.RoleVO;
import com.tedu.parkinglot.role.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    // 查询角色列表
    @GetMapping("select")
    public JsonResult selectRole(RoleQuery roleQuery){
        log.debug("查询参数{}", roleQuery);
        List<RoleVO> list=roleService.selectRole(roleQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult selectById(RoleSaveParam  roleSaveParam){
        log.debug("新增参数{}", roleSaveParam);
        roleService.save(roleSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("删除参数{}", id);
        roleService.delete(id);
        return JsonResult.ok();
    }

}
